package data.component;

import java.util.List;
import java.util.ArrayList;
import utils.Geometry;
import utils.Vector;

public class Wall extends Line{

    public String type;
    public Double scanQuality;
    public String id;
    public List<Opening> openings;

    public Wall(String id, Double[] start, Double[] end, String type)
    {
        super(start, end, false);
        this.id = id;
        this.type = type;
        this.openings = new ArrayList<Opening>();

    }

    public Wall(String id, Line line, String type)
    {
        super(line.start, line.end, false);
        this.id = id;
        this.type = type;
        this.openings = new ArrayList<Opening>();
        GetScanQuality(new Double[] { 0d, 0d });
    }

    public Double GetLength()
    {
        return this.length;
    }


    public void GetScanQuality(Double[] scanPoint)
    {
        var v1 = new Vector(start, scanPoint);
        var v2 = new Vector(end, scanPoint);
        scanQuality = Vector.CalcClockWiseAngle(v1, v2);
    }

    public String toString()
    {
        var shortId = id.length() > 5 ? id.substring(0, 5) : id;
        return String.format("start:[%d, %d]  end:[%d,%d] id:%s length:{%d}", start[0].intValue(),start[1].intValue(), end[0].intValue(), end[1].intValue(), shortId, Math.round(length));

    }
}
